<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自由讨论</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <style type="text/css" >
        .layui-tab-brief>.layui-tab-title .layui-this {
            color: #0B469F;
        }
        .layui-tab-brief>.layui-tab-title .layui-this:after {
            border-bottom: 2px solid #0B469F;
        }
        #first{
            margin: 0 auto;
            width: 950px;
            background-color: #F6F6F8;
        }
        .layui-laypage .layui-laypage-curr .layui-laypage-em {
            position: absolute;
            left: -1px;
            top: -1px;
            padding: 1px;
            width: 100%;
            height: 100%;
            background-color: #0B469F;
        }
    </style>
</head>
<body>
<!--<div id="title" style="margin: 0 auto;">-->
<!--    <h3>关于软件工程的相关问题</h3>-->
<!--</div>-->
<div id="title" style="margin-bottom: 10px;margin-top: 15px;padding-bottom: 20px;">
    <!--    <h2 align="center">关于软件工程的相关问题</h2>-->
</div>
<hr style="margin: 0 auto;width: 950px">
<div id="first" style="margin-top: 10px;">

</div>
<script>

    window.onload = function () {
        var topic = localStorage.getItem("topic");
        var publisherId = localStorage.getItem("publisherId");
        $.ajax({
            url:'http://106.14.215.182:9091/tby/ipos-discussion-publisher/getContext',
            type:"POST",
            data:JSON.stringify({
                topic:topic,
                publisherId:publisherId,
                returnContent:''
            }),
            contentType: 'application/json',
            dataType: 'json',
            success:function (result) {
                console.log(result)
                var ttitle = $("#title");
                var tbody = $("#first");
                $('#first').empty();
                var data = result.data;
                var obj1 = new Object();
                var obj2 = new Object();
                if(data.context.length == 0){
                    var html1 = '';
                    html1 = html1 + '    <h2 align="center">'+topic+'</h2>\n' +
                        '<hr style="margin: 0 auto;width: 950px">'
                    ttitle.append(html1);
                    ttitle.innerHTML = html1;
                }
                else
                {
                    for(var i =0 ;i<data.context.length;i++){
                        var html1 ='',html='';
                        obj1[i] = data.context[i];
                        obj2[i] = data.returnUserId[i];
                        if(i == 0){
                            var html1 = '';
                            html1 = html1 + '    <h2 align="center">'+topic+'</h2>\n' ;
                            ttitle.append(html1);
                            ttitle.innerHTML = html1;
                            html =html+  '<div style="height: 100px;">\n' +
                                '                    <div style="padding-top: 20px;padding-left: 20px">\n' +
                                '                    <p style="color: red;display: inline-block">发表人: '+obj2[i]+'</p>\n' +
                                '                    <p style="display: inline-block;font-size: 18px;margin-left: 50px "><a  style="color:#2D64B3">'+obj1[i]+'</a></p>\n' +
                                '                    </div>\n' +
                                '                </div>\n' +
                                '                <hr>';
                        }
                        else
                        {
                            html =html+  '<div style="height: 100px">\n' +
                                '                    <div style="padding-top: 20px;padding-left: 20px">\n' +
                                '                    <p style="color: red;display: inline-block">回复人: '+obj2[i]+'</p>\n' +
                                '                    <p style="display: inline-block;font-size: 18px;margin-left: 50px "><a  style="color:#2D64B3">'+obj1[i]+'</a></p>\n' +
                                '                    </div>\n' +
                                '                </div>\n' +
                                '                <hr>';
                        }
                    }
                    tbody.append(html);
                    tbody.innerHTML = html;
                }
            }
        })
    }
</script>
</body>
</html>